Skip to content

問題、写真、選択肢を表示できるようになった。#5

Open
daiki-sato wants to merge 1 commit intodevelopfrom
feature/1
Open

問題、写真、選択肢を表示できるようになった。#5
daiki-sato wants to merge 1 commit intodevelopfrom
feature/1

Conversation

@daiki-sato
Copy link
Copy Markdown
Owner

やったこと

  • 問題の表示

スクリーンショット 2022-04-19 23 58 32

やってないこと

  • クリック処理
  • 見た目

@daiki-sato daiki-sato self-assigned this Apr 19, 2022
@daiki-sato
Copy link
Copy Markdown
Owner Author

エラー出てます

(property) choices: string[]
型 'string' を型 'string[]' に割り当てることはできません。ts(2322)
index.tsx(7, 3): 予期された型は、型 'IntrinsicAttributes & ChoiceListProps & { children?: ReactNode; }' に対してここで宣言されたプロパティ 'choices' から取得されています

スクリーンショット 2022-04-19 23 59 48

スクリーンショット 2022-04-19 23 59 55

スクリーンショット 2022-04-20 0 00 31

</Typography>
</Box>
{quizData.map((quiz) => {
return <Quiz quiz={quiz} key={quiz.id}></Quiz>
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quiz は子コンポーネントを受け取るわけではないので、
<Quiz quiz={quiz} key={quiz.id} />
こうやって書きます

<>

<Box>
<Button variant="outlined">{choices}</Button>
Copy link
Copy Markdown

@yutomoriyasu yutomoriyasu Apr 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配列はそのまま中括弧で表示できないです

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

この
choices
って、配列では無い気がする??

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

配列か
なんかコードが色々変だね

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@daiki-sato がんばれ

@yutomoriyasu
Copy link
Copy Markdown

yutomoriyasu commented Apr 19, 2022

{quiz.choices.map((choices) => {
  return <ChoiceList choices={choices} key={choices.id}></ChoiceList>
})}

mapの中の引数は quiz.choices の一つ一つなので、型が stringになっちゃいます。
こういうのを防ぐには、map のなかの引数にも型付けをしましょう。

@daiki-sato
Copy link
Copy Markdown
Owner Author

理解

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants